package com.itheima.controller;

import com.itheima.domain.Department;
import com.itheima.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/department")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;
    @RequestMapping("/findAll")
    public ModelAndView findAll(ModelAndView modelAndView){
        List<Department> departmentList = departmentService.findAll();
        modelAndView.addObject("departmentList",departmentList);
        modelAndView.setViewName("subscribe-form");
        return modelAndView;
    }
}
